﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;

public partial class Interviewer_SendEmailNoticeHired : System.Web.UI.Page
{
    InterviewerMethord IM = new InterviewerMethord();
    string ApplicantID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ApplicantID = Request.QueryString["ID"].ToString();
        }
        catch (Exception ex)
        {
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblError.Text = "";
        lblSuccess.Text = "";
        try
        {
            if (txtDate.Text.Equals(""))
            {
                lblErrorDate.Text = "(*)";
                lblError.Text = "Check working date.";
            }
            else if (txtTime.Text.Equals(""))
            {
                lblErrorDate.Text = "";
                lblErrorDate.Text = "(*)";
                lblError.Text = "Check working time.";
            }
            else if (txtAddress.Text.Equals(""))
            {
                lblErrorDate.Text = "";
                lblErrorDate.Text = "";
                lblErrorAddress.Text = "(*)";
                lblError.Text = "Check work place.";
            }
            else
            {
                lblErrorDate.Text = "";
                lblErrorDate.Text = "";
                lblErrorAddress.Text = "";
                lblError.Text = "";
                MailMessage MailNet = new MailMessage();
                MailNet.From = new MailAddress("eprojectgroup1sem3@gmail.com");
                MailNet.To.Add(IM.ReturnEmailFollowApplicantID(ApplicantID));
                MailNet.Subject = "Notice of the time of interview ABC company";
                MailNet.Body = "please inform!\n We are pleased to inform you that you have to get into our company ABC with your chosen industry. And we were scheduled to work for you as follows: \n Working date: "+txtDate.Text+" \n Time: "+txtTime.Text+" \n Work place: "+txtAddress.Text;
                SmtpClient sc = new SmtpClient("smtp.gmail.com");
                sc.Port = 25;
                sc.Credentials = new NetworkCredential("eprojectgroup1sem3@gmail.com", "admin!@#$%^");
                sc.EnableSsl = true;
                sc.Send(MailNet);
                Response.Write("<script type=\"text/javascript\">alert(\"Email has been sent\");window.location = \"ApplicantManager.aspx\";</script>");
            }
        }
        catch (Exception ex)
        {
        }
    }
    protected void btnSaveLast_Click(object sender, EventArgs e)
    {
        Response.Redirect("ApplicantManager.aspx");
    }
}